package com.example.module_web.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.module_web.R;
import com.example.module_web.beans.Consignment;

import java.util.HashMap;
import java.util.List;

/**
 * Created by ASUS on 2018/3/12.
 */

public class ConsignmentAdapter extends FormAdapter<Consignment>{

    public ConsignmentAdapter(Context context, List<Consignment> items) {
        super(context, items);
    }

    @Override
    public HashMap<String, View> onBindItemViewId(HashMap<String, View> holder,View itemView) {
        holder.put(NUM,itemView.findViewById(R.id.item_form_num));
        holder.put(POSTAGE,itemView.findViewById(R.id.item_form_postage));
        holder.put(DATE,itemView.findViewById(R.id.item_form_date));
        holder.put(WEIGHT,itemView.findViewById(R.id.item_form_weight));
        holder.put(ADDRS,itemView.findViewById(R.id.item_form_addrs));
        holder.put(PAIDPRICE,itemView.findViewById(R.id.item_form_paidPrice));
        holder.put(PRODUCT,itemView.findViewById(R.id.item_form_product));
        return holder;
    }

    @Override
    protected int setItemLayoutId() {
        return R.layout.web_item_frag02_consignment;
    }

    @Override
    protected void onBindFormData(HashMap<String, View> holder, Object o) {
        Consignment consignment = (Consignment) o;
        ((TextView)holder.get(NUM)).setText(String.format("%s)", String.valueOf(consignment.getNumber())));
        ((TextView)holder.get(POSTAGE)).setText(String.format("￥%s",String.valueOf(consignment.getPostPrice())));
        ((TextView)holder.get(DATE)).setText(consignment.getDate());
        ((TextView)holder.get(WEIGHT)).setText(String.valueOf(consignment.getWeight()));
        ((TextView)holder.get(ADDRS)).setText(consignment.getAddress());
        ((TextView)holder.get(PAIDPRICE)).setText(String.valueOf(consignment.getPaidPrice()));
        ((TextView)holder.get(PRODUCT)).setText(consignment.getProduct());
    }
}
